<template>
  <v-container>
    <v-row>
      <v-col>
        <v-card>
          <v-card-text>
            <v-alert outlined type="warning" prominent border="left">
              工厂方法模式演示
            </v-alert>
          </v-card-text>
        </v-card>
      </v-col>
    </v-row>
    <v-row>
      <v-col>
        <v-card>
          <v-card-text class="mt-2">
            <v-row>
              <v-col v-for="(d, index) in infos" :key="index" cols="12">
                {{ d }}
              </v-col>
            </v-row>
          </v-card-text>
        </v-card>
      </v-col>
    </v-row>
  </v-container>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import {
  AddFactory,
  IFactory
} from "@/design-pattern/08-factory-func/FactoryFuncV2";

@Component({})
export default class PageV2 extends Vue {
  // region Prop
  // endregion
  // region Data
  infos: string[] = [];
  // endregion
  // region computed
  // endregion
  // region watch
  // endregion
  // region method
  // endregion
  // region hook
  created() {
    // 在工厂方法模式中 使用到一个实例的多次处理时,这里只用修改下面语句即可
    const operFactory: IFactory = new AddFactory();
    const oper = operFactory.CreateOperation();
    const oper1 = operFactory.CreateOperation();
    const oper2 = operFactory.CreateOperation();
    const oper3 = operFactory.CreateOperation();
    oper.NumberA = 11;
    oper.NumberB = 13;

    this.infos.push(oper.GetResult()!.toString());
  }
  // endregion
}
</script>

<style lang="scss"></style>
